package demo.marsdonne.liquibasespring;

import liquibase.integration.spring.SpringLiquibase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

@SpringBootApplication
public class LiquibaseSpringApplication {

    @Autowired
    private DataSource dataSource;

    @Bean
	public SpringLiquibase liquibase() {
        SpringLiquibase springLiquibase = new SpringLiquibase();
        springLiquibase.setDataSource(dataSource);
        springLiquibase.setContexts("test, production");
        springLiquibase.setChangeLog("classpath:db/changelog/db.changelog-master.xml");
		return springLiquibase;
	}

	public static void main(String[] args) {
		SpringApplication.run(LiquibaseSpringApplication.class, args);
	}
}
